﻿@using CodeCamp.Models.EventMgmt
@model EventMgmtUsersViewModel
@{
    @* ViewBag.RegistrationUrl set in code - SetSharedViewBagProperties *@
    ViewBag.EventName = "";
    ViewBag.Title = "";
    if ((@Model != null) && (@Model.EventDisplayName != null))
    {
        ViewBag.Title = @Html.Encode(@Model.EventDisplayName + " | Users");
        ViewBag.EventName = @Model.EventDisplayName;
    }
    else
    {
        ViewBag.Title = "Code Camp | Users";
        ViewBag.EventName = "Code Camp";
    }
}

@section headaddon {
<style>
    table
    {
        border-collapse: collapse;
        border: solid 1px;
        margin: 0;
    }
    th
    {
        padding: 4px;
    }
    td 
    {
        padding: 4px;
    }
    td.datetime-nowrap
    {
        white-space:nowrap;
    }
    #content
    {
        width: 900px;
    }
</style>
}

<h2 class="title">@ViewBag.Title</h2>

<table>
    <tbody>
        <tr><td colspan="9">Last Login time is server time.  Current server time: @DateTime.Now.ToString("yyyy-MM-dd  HH:mm:ss")</td></tr>
        <tr><th>User</th><th>Presenter</th><th>Created</th><th>Approved</th><th>Locked Out</th><th>Online</th>
            <th>Last&nbsp;Login / Activity</th><th>Role(s)</th><td>&nbsp;</td></tr>
        @foreach (EventMgmtUserViewModel user in @Model.UserList)
        {
        <tr>
            <td>@user.Username<br />
                @user.UserEmailAddress
            </td>
            <td>
                @if (@user.PresenterId.HasValue && @user.PresenterId.Value != 0)
                {
                    <text>&nbsp;|&nbsp;</text>@Html.ActionLink(@user.PresenterName, "Details", "Presenters", new { id = @user.PresenterId.Value }, null);<br />
                    @user.PresenterEmailAddress
                }
            </td>
            <td>@if (@user.UserCreationDate.HasValue)
                { <text>@user.UserCreationDate.Value.ToShortDateString()</text> }
                else
                { <text>&nbsp;</text> }</td>
            <td>@if (user.IsApproved) { <text>yes</text> } else {<text>NO</text>}</td>
            <td>@if (user.IsLockedOut) { <text>Locked</text> } else {<text>&nbsp;</text>}</td>
            <td>@if (user.IsOnline) { <text>Online</text> } else {<text>&nbsp;</text>}</td>
            <td class="datetime-nowrap">@if (user.LastLoginDate.HasValue)
                { <text>@user.LastLoginDate.Value.ToString("yyyy-MM-dd  HH:mm")<br /></text> }
                else
                { <text>&nbsp;<br /></text> }
                @if (user.LastActivityDate.HasValue && (!user.LastLoginDate.HasValue || (user.LastActivityDate != user.LastLoginDate)))
                { <text>@user.LastActivityDate.Value.ToString("yyyy-MM-dd  HH:mm")</text> }
                else
                { <text>&nbsp;</text> }
            </td>
            @* <td>@user.LastActivityDate</td> *@ @* LastActivityDate seems to always be same as LastLoginDate *@
            <td>
                @if (!string.IsNullOrWhiteSpace(user.ProviderUserKey))
                {
                    @Html.ActionLink("Edit", "UserEdit", new { id = user.ProviderUserKey })
                }
            </td>
        </tr>
        }
        <tr><td colspan="9">Page @Model.PageNumber of @Model.TotalPages
        @if (@Model.TotalPages > (Decimal)1.0)
        {
            <b>Time to add paging!</b>
        }
        </td></tr>
    </tbody>
</table>


@*
@section sidebar {
    @Html.Partial("SidebarCommonPartial")
}
*@
